package interview;

public class interview_16_14 {
    public int[] bestLine(int[][] points) {
        int numOfPoints = points.length;
        int []res= new int[]{0,1};
        int max_NumOfPoint = 2;
        //外循环确定点
        for(int i = 0;i<numOfPoints - 1;i++){
            int x1 = points[i][0];
            int y1 = points[i][1];

            //内循环确定一条直线
            for(int j = i + 1;j<numOfPoints;j++){
                int x2 = points[j][0];
                int y2 = points[j][1];
                int line_Points = 2;
                //内内循环确定在线上点的个数
                for(int k = j + 1;k < numOfPoints;k++){
                    int x3 = points[k][0];
                    int y3 = points[k][1];
                    if((y1-y2)*(x1-x3) == (y1-y3)*(x1-x2)){
                        line_Points++;
                    }
                    if(line_Points > max_NumOfPoint){
                        res[0] = i;
                        res[1] = j;
                        max_NumOfPoint = line_Points;
                    }
                }
            }
        }
        return res;
    }

}
